package com.dnxh.controller;


import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.dnxh.constant.CustomResult;
import com.dnxh.entity.BasicMeeting;
import com.dnxh.entity.SearchBasicMeetingVo;
import com.dnxh.entity.request.SearchBasicMeetingRequest;
import com.dnxh.entity.request.SetLocationRequest;
import com.dnxh.service.BasicMeetingService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author zhiqiu
 * @since 2022 -04-13
 */
@RestController
@RequestMapping("/basicMeeting")
public class BasicMeetingController {

	@Resource
	private BasicMeetingService basicMeetingService;
	
	/**
	 * Search list.
	 *
	 * @param request the request
	 * @return the list
	 */
	@PostMapping("/search")
	public CustomResult search(@RequestBody SearchBasicMeetingRequest request){
		return basicMeetingService.search(request);
	}
	
	/**
	 * 设置地址
	 *
	 * @param request the request
	 * @return the custom result
	 */
	@PutMapping("/set")
	public CustomResult setLocation(@RequestBody SetLocationRequest request){
		return basicMeetingService.setLocation(request);
	}
	
	/**
	 * Del custom result.
	 *
	 * @param id the id
	 * @return the custom result
	 */
	@DeleteMapping("/{id}")
	public CustomResult del(@PathVariable("id") Long id){
		return basicMeetingService.del(id);
	}
	
	/**
	 * 发送会议通知链接
	 *
	 * @param id the id
	 * @return the custom result
	 */
	@PutMapping("/put/{id}")
	public CustomResult sendMeetingEmail(@PathVariable("id") Long id){
		return basicMeetingService.sendMeetingEmail(id);
	}
	
	/**
	 * 签到
	 *
	 * @param id the id
	 */
	@GetMapping("/check/{id}")
	public void checkIn(@PathVariable("id") Long id){
		basicMeetingService.update (Wrappers.<BasicMeeting>lambdaUpdate ()
				.set (BasicMeeting::getSignIn,0)
				.eq (BasicMeeting::getId,id));
	}
}

